package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.AccountDao;
import io.renren.modules.sys.entity.AccountEntity;
import io.renren.modules.sys.entity.AccountLiuShui;
import io.renren.modules.sys.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("accountService")
public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> implements AccountService {
    @Autowired
    AccountDao accountDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<AccountEntity> page = this.selectPage(
                new Query<AccountEntity>(params).getPage(),
                new EntityWrapper<AccountEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<AccountLiuShui> findAccountInOutList(Map<String, Object> params) {
        return accountDao.findAccountInOutList(params);
    }

    @Override
    public PageUtils queryAccount(Map<String, Object> params) {
        Page<AccountEntity> page = this.selectPage(
                new Query<AccountEntity>(params).getPage(),
                new EntityWrapper<AccountEntity>().orderBy("id", false)
        );

        return new PageUtils(page);
    }
}
